from redis import StrictRedis
import logging

class Config(object):

    """项目的配置"""
    DEBUG = True

    SECRET_KEY = "aixKQBB7+vWadDJRt+bIDCdsXa9WVqRtbaWlJPQRDVVoQPZ0QPd/7EdbyLjBrYRw"

    SQLALCHEMY_DATABASE_URI = 'mysql://root:1027@127.0.0.1:3306/information15k'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # 在请求借宿时，如果指定此配置为True，那么SQLALchemy会自动执行一次 db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # Redis的配置
    REDIS_HOST= "127.0.0.1"
    REDIS_PORT= 6379

    # Session保存配置
    SESSION_TYPE = "redis"
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 设置session过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFRTIME = 86400 *2

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):

    """开发环境下的配置"""
    DEBUG = True



class ProductionConfig(Config):

    """生产环境下的配置"""
    DEBUG = False
    # 生产环境下的数据库配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:1027@127.0.0.1:3306/information15k'
    LOG_LEVEL = logging.WARNING



class TestingConfig(Config):

    """单元测试环境下的配置"""
    DEBUG = True
    TESTING = True


config = {
    "development":DevelopmentConfig,
    "production":ProductionConfig,
    "testing":TestingConfig
}